<?php
declare (strict_types=1);

namespace app\business\controller;

use think\App;
use think\facade\View;

class ProductCate extends Base
{

    protected $pk = 'id';

    protected $validate = 'ProductCate';

    protected $model = '\app\common\model\ProductCate';

    public function initialize()
    {
        parent::initialize();
    }


    public function index()
    {
        View::assign('list', $this->model::getAll());
        return View::fetch();
    }

    public function edit($name = '', $id = '', $pid = '', $tpl = 'product_cate/edit')
    {
        $p_title = '';
        if ($pid) {
            $p_title = $this->model::where('id', $pid)->value('title');
        }
        View::assign('p_title', $p_title);
        return parent::edit($name, $id, $tpl);
    }


    public function getCate()
    {
        $id = $this->request->param('id', 0);
        return json($this->model::getBusinessCate($id,$this->business->cate_1));
    }

}
